home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group97a.txt
/
000125_icon-group-sender _Sat May 10 20:35:43 1997.msg
< prev
next >
Wrap
Internet Message Format
|
2000-09-20
|
2KB
Received: from kingfisher.CS.Arizona.EDU by cheltenham.cs.arizona.edu; Mon, 12 May 1997 08:24:04 MST
Received: by kingfisher.CS.Arizona.EDU; (5.65v3.2/1.1.8.2/08Nov94-0446PM)
id AA02983; Mon, 12 May 1997 08:24:04 -0700
To: icon-group@cs.arizona.edu
Date: Sat, 10 May 1997 20:35:43 +1000
From: Stuart.Robinson@anu.edu.au (Stuart Robinson)
Message-Id: <Stuart.Robinson-1005972035440001@asianstmg-212.anu.edu.au>
Organization: ANU
Sender: icon-group-request@cs.arizona.edu
Subject: Problem with Program
Errors-To: icon-group-errors@cs.arizona.edu
Status: RO
Content-Length: 1528
Could someone tell me why the program below isn't working? It's late and
I must be overlooking something. Given input like the following
This is a sample line 1{S {S
This is a sample line 2{A {A
This is a sample line 3{O {O
it should be produce the following output
S: 2
A: 2
O: 2
Thanks in advance.
----------------
procedure main()
chars := &letters ++ &digits ++ '{.*[]?' #valid characters
noS := 0
noA := 0
noO := 0
while line := read() do #read in line
{
line ? #textscan line
{
while tab(upto(chars)) do #look for valid character
{
word := tab(many(chars)) #word = valid character through
next invalid character
word ? #textscan word
{
while tab(upto("{") +1) do #move just past bracket (will
fail if there is none)
{
wordfrag := move(1) #wordfrag = one character past bracket
case wordfrag of #if wordfrag is
{
"S" : noS +:= 1 #S, then increment noS by 1
"A" : noA +:= 1 #A, then increment noA by 1
"O" : noO +:= 1 #O, then increment noO by 1
}
}
}
}
}
}
write( "S: " || noS || \n || "A: " || noA || \n || "O: " || noO )
end
--
Stuart Robinson <Stuart.Robinson@anu.edu.au>
The Australian National University